package com.tehui.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tehui.R;
import com.tehui.utils.ui.UiUtils;

/**
 * Created by jasmine on 2017/3/22.
 */

public class HomeGridViewAdapter extends BaseAdapter {

    private int[]    image = {R.drawable.fl1_2, R.drawable.fl1_3, R.drawable.fl_11, R.drawable.fl1_4, R
            .drawable.fl2_2, R.drawable.fl1_5, R.drawable.fl1_6, R.drawable.fl2_1, R.drawable.fl1_8, R
            .drawable.fl2_4};
    private String[] name  = {"女装", "男装", "内衣", "居家", "数码家电", "美食", "母婴", "鞋包配饰", "美妆", "文体车品"};

    @Override
    public int getCount() {
        return image.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View inflate = View.inflate(UiUtils.getContext(), R.layout.item_home_grid, null);
        ImageView img = (ImageView) inflate.findViewById(R.id.ivFl);
        TextView tvName = (TextView) inflate.findViewById(R.id.tvName);
        img.setImageResource(image[position]);
        tvName.setText(name[position]);
        return inflate;
    }
}
